<template>
  <el-dialog
    :model-value="dialogVisible"
    title="Tips"
    width="30%"
    :before-close="handleClose"
  >
    <span>This is a message</span>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="handleClose">Cancel</el-button>
        <el-button type="primary" @click="handleConfirm"> Confirm </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref } from 'vue'
import { ElMessageBox } from 'element-plus'

const emits = defineEmits(['update:modelValue', 'onConfirm'])

const dialogVisible = ref(false)

const handleClose = (done) => {
  emits('update:modelValue', false)
}
const handleConfirm = () => {
  emits('onConfirm', {
    id: 1,
    name: '张三'
  })
  handleClose()
}
</script>
<style scoped>
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
